
import 'package:cunyutech_flutter_core/cunyutech_flutter_core.dart';
import 'package:cunyutech_flutter_ui/cunyutech_flutter_ui.dart';
import 'package:cunyutech_flutter_ui/src/funcs/main.dart';
import 'package:flutter/widgets.dart';

class SliverPersistentHeaderChildDelegate extends SliverPersistentHeaderDelegate {
  final Widget child;

  SliverPersistentHeaderChildDelegate({
    this.child
  });

  @override
  Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
    print("shrinkOffset: $shrinkOffset, overlapsContent: $overlapsContent");
    NumberRange range = NumberRange(0, maxExtent.toInt());
    double percent = range.percent(shrinkOffset);

    return Stack(
      children: <Widget>[
        Opacity(
          opacity: percent,
          child: BlurWidget(
            enable: true,
            blur: 6,
            height: maxExtent,
            width: CYScreen.width,
            color: Color(0x99000000),
          ),
        ),
        child
      ],
    );
  }

  @override
  double get maxExtent => 33;

  @override
  double get minExtent => 33;

  @override
  bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
    return true;
  }
}